﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>您心中的英国印象</title>
<link href="css/popup.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">

    var chineseCode = 2052;
    var checknum = 0;
    function matchem(obj) {


        if (obj.checked) {

            if (checknum == 3) {
                obj.checked = false;
                alert("最多只能选择三项");

            }
            else {
                checknum++;
            }
        }
        else {
            checknum--;
        }

   
     
    }
    //2填充投票选项
    function fill(keywordArray) {
        var sT = "<li><span  ><input name='keyGp' type='checkbox' onclick='matchem(this)' ";
        var eN = "</span></li>";
        var lastHtml = "";
        var newdata = keywordArray.split('|');
        for (var i = 0; i < newdata.length && i<11; i++) {
         
             
                lastHtml += sT + "value='" + newdata[i] + "'/></span><span style='color:#fff'> " + newdata[i] + eN;
            
            
        }

       
    document.getElementById("keyZone").innerHTML = lastHtml;

    }
    //1请求已发布的关键字选项
    function LoadPost() {

        
        $.post(
        "Vote.aspx", { code: chineseCode },
         function (data) {

           
            if (data != "0") {
                fill(data)

            } else {
                alert("网络连接异常");
            }


           }
        );





    }
    //字数检测
    function FontSum() {
        alert("helo");
    }
    //发送调查结果
    function sendRes() {
        //debugger;
        var ches = document.getElementsByName("keyGp");

        var paid = null;


        var chstr = "";
        for (var i = 0; i < ches.length; i++) {

            
            if (ches[i].checked) {

                chstr += ches[i].value + "|";

            }

        }

      
        if ($("#votex").val() == "不超过5个字") {
            $("#votex").val("");
          
            


        }
        if (($("#votex").val() != "" || chstr != "") ) {

            var ches1 = chstr.split('|');
            if (ches1.length == 2) {
                paid = { "1": ches1[0], code1: chineseCode, x: $("#votex").val() };
            }
            if (ches1.length == 3) {
                paid = { "1": ches1[0], "2": ches1[1], code1: chineseCode, x: $("#votex").val() };
            }
            if (ches1.length == 4) {
                paid = { "1": ches1[0], "2": ches1[1], "3": ches1[2], code1: chineseCode, x: $("#votex").val() };
            }
            $.post(
         "Vote.aspx", paid, function (data) {
             window.location = "result.html";
         }
        );
        }
     else {
         alert("至少选择一项");
        }
        
    }
</script>
</head>
<body onload="LoadPost()">
<div id="vote">
	<div class="close"><a href="#" onclick="parent.tb_remove();"><img src="images/icon_vote_close.gif" alt="" /></a></div>
    <div class="content">
    	<form action="result.html" method="post">
    	<div class="title">请选择以下最能表达英国印象的词语(最多选三项)</div>
        <div class="vote">
          
        	<ul id="keyZone">
            	
            </ul>
        </div>
        <dl>
            <dt>输入你的英国印象:</dt>
            <dd><input id="votex" value="不超过5个字"  onfocus="if(this.value=='不超过5个字'){this.value=''}"  onkeydown="if(this.value.length>5){alert('不要超过5个字')}" type="text" /></dd>
        </dl>
        <div class="votebtn"><input id="voteHTML"   type="button" value="" onclick="sendRes()" /></div>
        </form>
    </div>
</div>
</body>
</html>
